set more 1

/*
File:	cepr_org_hours.do
Date:	Nov 14, 2005, CEPR ORG Version 1.0
		Feb 10, 2009
		Mar 12, 2015, CEPR ORG Version 2.0
		Apr 1, 2015, CEPR ORG Version 2.0.1
		Mar 1, 2016, CEPR ORG Version 2.1
		Oct 12, 2016, CEPR ORG Version 2.1.1
		Feb 9, 2017, CEPR ORG Version 2.2
		Apr 21, 2017, CEPR ORG Version 2.2.1
		Apr 10, 2018, CEPR ORG Version 2.3
		Mar 22, 2019, CEPR ORG Version 2.4
		Jul 24, 2019, CEPR ORG Version 2.4.1
	    Feb 05, 2020, CEPR ORG Version 2.5
	
Desc:	Creates consistent hours variables for CEPR extract of CPS ORG
Note:	See copyright notice at end of program.
*/

/* Determine data year */
local year=year in 1
if `year'==-17345 {local year  = 1980}
di "`year'"

/* collect NBER hours variables */

	/* actual hours last week */

if 1979<=`year' & `year'<=1993 {
replace hourslwa=. if hourslwa<0
}

lab var hourslwa "Hours last week, all jobs"
notes hourslwa: Unedited
notes hourslwa: Available 1979-93 only
notes hourslwa: CPS: a-hrsl
notes hourslwa: Made negative values = missing

lab var hourslw "Hours last week, all jobs"
notes hourslw: Edited
notes hourslw: CPS: a-hrsl, pehractt

gen hourslwm=.
lab var hourslwm "Hours last week, main job"
notes hourslwm: Actual hours worked on main job
notes hourslwm: Edited
notes hourslwm: CPS: pehract1
notes hourslwm: Available 94-on

if 1979<=`year' & `year'<=1993 {
rename reasonlw reason79
lab var reason79 "Why <35 hours last week"
#delimit ;
lab def reason79
1 "Slack work"
2 "Material shortage"
3 "Plant or machine repair"
4 "New job started during week"
5 "Job terminated during week"
6 "Could only find part-time work"
7 "Holiday"
8 "Labor dispute"
9 "Bad weather"
10 "Own illness"
11 "On vacation"
12 "Too busy with school, house"
13 "Did not want full-time work"
14 "Full-time work week is <35 hours"
15 "Other"
;
#delimit cr
lab val reason79 reason79
notes reason79: Available 1979-93 only
notes reason79: See also why3579
notes reason79: CPS: a-ftreas

gen byte reason94=.
lab var reason94 "Why <35 hours last week"
notes reason94: Available 1994- only
notes reason94: CPS: perhrrsn3
}


if 1979<=`year' & `year'<=1993 {
rename absentlw absent79
}
lab var absent79 "Why absent last week"
#delimit ;
lab def absent79
1 "Own illness"
2 "On vacation"
3 "Bad weather"
4 "Labor dispute"
5 "New job to begin w/in 30 days"
6 "Temporary layoff (<30 days)"
7 "Indefinite layoff (30+ days)"
8 "Other"
;
#delimit cr
lab val absent79 absent79
notes absent79: Available 1979-93 only
notes absent79: CPS: a-whyabs

gen byte absent94=.

#delimit ;
lab def absent94
1 "Layoff"
2 "Slack work/business conditions"
3 "Waiting for a new job to begin"
4 "On vacation"
5 "Own illness"
6 "Child-care problems"
7 "Other family/personal"
8 "Maternity/paternity"
9 "Labor dispute"
10 "Bad weather"
11 "School/training"
12 "Civic/military duty"
13 "Does not work"
14 "Other"
;
#delimit cr
lab val absent94 absent94

lab var absent94 "Why absent last week"
notes absent94: Available 1994- only
notes absent94: CPS: peabsrsn



/* Additional Absent From Work Variable */


if 1979<=`year' & `year'<=1993 {
gen byte abpaid=.
}

lab var abpaid "Paid for time off last week"
notes abpaid: Availbe if 4<=absent94<=12 | absent94==14
notes abpaid: Available 1994- only
notes abpaid: CPS: peabspdo

	/* usual weekly hours */
	
if 1979<=`year' & `year'<=1993 {
lab var uhours "Usual hours, main job"
notes uhours: Unedited
notes uhours: Available 1979-93 only
notes uhours: CPS: a-uslhrs
}


lab var uhourse "Usual hours, main job"
notes uhourse: Edited
notes uhourse: CPS: a-uslhrs, peernhro

if 1979<=`year' & `year'<=1993 {
rename why35lw why3579
}
lab var why3579 "Why usually <35 hours"

#delimit ;
lab def why3579
1 "Slack work"
2 "Material shortage"
3 "Plant or machine repair"
4 "New job started during week"
5 "Job terminated during week"
6 "Could only find part-time work"
7 "Holiday"
8 "Labor dispute"
9 "Bad weather"
10 "Own illness"
11 "On vacation"
12 "Too busy with school, house"
13 "Did not want full-time work"
14 "Full-time work week is <35 hours"
15 "Other"
;
#delimit cr

lab val why3579 why3579
notes why3579: Available 1979-93 only
notes why3579: See also reason79
notes why3579: CPS: a-ftreas

gen byte why3594=.

#delimit ;
lab def why3594
1 "Slack work, FT"
2 "Seasonal, FT"
3 "Job started or end last week, FT"
4 "On vacation, FT"
5 "Own illness, FT"
6 "Holiday, FT"
7 "Child-care problems, FT"
8 "Other family obligations, FT"
9 "Labor dispute, FT"
10 "Bad weather, FT"
11 "School/training, FT"
12 "Civic/military, FT"
13 "Other, FT"
14 "Slack work, PT"
15 "Could only find PT work, PT"
16 "Seasonal, PT"
17 "Child-care problems, PT"
18 "Other family obligations, PT"
19 "Own illness, PT"
20 "School/training, PT"
21 "Soc. Sec. earnings limitation, PT"
22 "Workweek <35 hours, PT"
23 "Other, PT"
;
#delimit cr
lab val why3594 why3594

lab var why3594 "Why usually <35 hours"
notes why3594: Available 1994- only
notes why3594: FT, PT refer to usual work schedule
notes why3594: CPS: prptreas


	/* part-time for economic reasons */
	
if 1979<=`year' & `year'<=1988 {
gen byte ptecon=0 if ftpt79==1 | ftpt79==2 | ftpt79==4 /* employed only */
replace ptecon=1 if ftpt79==2
/* in NBER, "ptstat" variable appears to be inconsistent with ftpt79 */
}
if 1989<=`year' & `year'<=1993 {
gen byte ptecon=0 if 2<=ftpt89 & ftpt89<=5  /* employed only */
replace ptecon=1 if ftpt89==3 | ftpt89==5
}

lab var ptecon "PT, economic reasons"
notes ptecon: CPS: derived from a-wkstat, prwkstat

	/* unemployed part-timers */
	
if 1979<=`year' & `year'<=1988 {
gen byte unempt=0 if ftpt79==3 | ftpt79==5 /* unemployed only */
replace unempt=1 if ftpt79==5
}
if 1989<=`year' & `year'<=1993 {
gen byte unempt=0 if ftpt89==6 | ftpt89==7  /* unemployed only */
replace unempt=1 if ftpt89==7
}

lab var unempt "Unemployed, PT"
notes unempt: CPS: derived from a-wkstat, prwkstat

if 1979<=`year' & `year'<=1993 {
gen byte hrmgfail=.
gen byte prhrusl=.
gen byte pehrusl1=.
gen byte hrsvary=.
gen byte pehrusl2=.
gen byte pehruslt=.
gen byte peernhro=.
}


lab var prhrusl "Usual hours, Basic CPS"
#delimit ;
lab def prhrusl
1 "0-20"
2 "21-34"
3 "35-39"
4 "40"
5 "41-49"
6 "50 or more hrs"
7 "Varies, FT"
8 "Varies, PT"
;
#delimit cr

lab val prhrusl prhrusl
notes prhrusl: Available 1994- only
notes prhrusl: CPS: prhrusl

lab var pehrusl1 "Usual hours, main (BLS)"
notes pehrusl1: Keeps "hours vary"=-4
notes pehrusl1: Extracted 1994- only; prior to 1994, see uhourse
notes pehrusl1: Basic CPS: hours per week USUALLY work at main job?
notes pehrusl1: CPS: pehrusl1

lab var hrsvary "Hours vary, main job"
notes hrsvary: Available 1994- only
notes hrsvary: CPS: pehrusl1==-4

lab var pehrusl2 "Usual hours, 2nd job (BLS)"
notes pehrusl2: Keeps "hours vary"=-4
notes pehrusl2: Extracted 1994- only; prior to 1994, see uhourse
notes pehrusl2: Basic CPS: hours per week USUALLY work at other job(s)?
notes pehrusl2: CPS: pehrusl2

lab var pehruslt "Usual hours, all (BLS)"
notes pehruslt: Keeps "hours vary"=-4

lab var peernhro "Usual hours, ORG (BLS)"
notes peernhro: ORG: hours usually work per week at this rate?
notes peernhro: CPS: peernhro

/* impute hours for "hours vary" respondents 1994- */

if 1979<=`year' & `year'<=1993 {
gen byte imphrs=.
/* to simplify calculations later, set hours imputed to zero (rather
than missing) here */
gen byte hrsimptd=0
/* to simplify calculations later, set uhoursi (usual weekly hours
including imputation) equal to uhourse for years before the hours
vary response was permitted */
gen byte uhoursi=uhourse
replace uhoursi=. if uhoursi==0
}

lab var imphrs "Hours, main job (imputed)"
notes imphrs: Assigned to respondents "hours vary" using regression
notes imphrs: Regression excludes industry, occupation, union variables
notes imphrs: Ind, occ, union vars significantly reduces imputation match rate

lab var hrsimptd "Hours imputed"
notes hrsimptd: See imphrs

lab var uhoursi "Hours, w/ imputation"
notes uhoursi: See imphrs
notes uhoursi: CPS pehrusl1 variable, with imputed hours where pehrusl1==-4

/* BLS imputations for hours */

gen byte blsimpt=.
replace blsimpt=0 if I25a==0
replace blsimpt=1 if 0<I25a & I25a~=.

lab var blsimpt "BLS allocated weekly hours"
notes blsimpt: Indicates BLS has allocated usual weekly hours at main job
notes blsimpt: CPS: derived from a%uslhrs, pxhrusl1

/* 
Copyright 2020 CEPR and John Schmitt

This file is part of the cepr_org_master.do program. This file and all
programs referenced in it are free software. You can redistribute the
program or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
USA.
*/
